<?php
namespace app\common\model;

class QuestionType extends Base
{
    protected $hidden = [
        'create_time','update_time','status'
    ];

    public function question()
    {
        return $this->hasMany(Question::class);
    }
    
    public function saveChange($data){
        $data['update_time'] = time();
        if(is_numeric($data['id'])){
            return $this->validate(true)->allowField(true)->save($data,[$this->getPk()=>$data['id']]);
        }else{
            $data['create_time'] = time();
            return $this->validate(true)->allowField(true)->save($data);
        }
    }

    public function getList($map = []){
        return $this->where($map)
            ->order('sort')
            ->paginate('',false,['query'=>request()->param()]);
    }
}